
import 'package:app_core/src/utils/observers.dart';
import 'package:app_core/src/utils/screen_adapter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../utils/lang/translations_service.dart';
import 'config.dart';


//你看一下我现在core层设计，如果我的core要支持多语言和主题切换，目前支持吗
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // static GlobalKey globalKey = GlobalKey();
  static final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
        designSize: ScreenAdapter.designSize,///设计稿尺寸
        builder: (context, child) {
          return GetMaterialApp(
            // key: MyApp.globalKey,
            navigatorKey: MyApp.navigatorKey,
            theme: appGlobalConfig.appConfig.theme,
            initialRoute: appGlobalConfig.appConfig.initRouter,
            getPages: appGlobalConfig.appConfig.getPages,
            debugShowCheckedModeBanner: false,
            navigatorObservers: [FlutterSmartDialog.observer,CustomRouteObservers.observer],
            builder: FlutterSmartDialog.init(
              loadingBuilder: appGlobalConfig.dialogConfig.loadingWidget,
              toastBuilder: appGlobalConfig.dialogConfig.toastWidget,
              notifyStyle: appGlobalConfig.dialogConfig.notifyStyle,
            ),
            translations: TranslationsService(),
            locale: Get.deviceLocale,
            fallbackLocale: Locale('en'),
          );
        });
  }
}
